﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using KCL.Code.Data;
using KCL.Code.Business;

namespace KCL.Summary
{
    public partial class UnfinishedProducts : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Page.IsPostBack == false)
            {
                this.BindDataForSearchCriteria();
            }
            if (Session[SessionManager.InSection] != null)
            {
                if ((int)Session[SessionManager.InSection] != 1)
                {
                    Response.Redirect("../");
                }
            }
            else
            {
                Response.Redirect("../");
            }
        }

        private void BindDataForSearchCriteria()
        {
            DataTable data = new DataTable();
            Search searcher = new Search();

            data = searcher.GetAllProductSize();
            ddlSize.DataSource = data;
            ddlSize.DataValueField = "Size";
            ddlSize.DataBind();

            data = searcher.GetAllMaterial();
            ddlMaterial.DataSource = data;
            ddlMaterial.DataValueField = "Material";
            ddlMaterial.DataBind();

            data.Dispose();
        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("/Default.aspx");
        }

        protected void dsUnfinishedProducts_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            if (e != null)
            {
                e.InputParameters["size"] = ddlSize.SelectedValue;
                e.InputParameters["material"] = ddlMaterial.SelectedValue;
                e.InputParameters["description"] = txtDescription.Text.Trim();
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            
        }

        //protected void dsUnfinishedProducts_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        //{
        //    e.InputParameters["size"] = ddlSize.SelectedValue;
        //    e.InputParameters["material"] = ddlMaterial.SelectedValue;
        //    e.InputParameters["description"] = txtDescription.Text.Trim();
        //}
    }
}